/**************************************************************************************
*
*	Copyright (C) 2009 Brent Andrew O. Chua - See LICENSE.txt for more info.
*		
*	Filename	-	HashedString.h
*
*	Description -	Creates a unique identifier from a given string.
*
*	Comments	-
*
*	Modification History:
*			Name			   Date					Description
*			CodeSushi	-	03/07/2009	-	Creation of this file
**************************************************************************************/

#ifndef _PSX_HASHED_STRING_H_
#define _PSX_HASHED_STRING_H_

#include "PulseSTD.h"
#include "String.h"

namespace Pulse
{
	class HashedString
	{
	public:

		explicit HashedString( const CHAR * const pIdentStr );

		ULONG GetHashedID( void ) const;

		const CHAR * const GetString( void ) const;

		static void * HashName( const CHAR * pIdentStr );

		BOOL operator < ( const HashedString &rhs ) const;

		BOOL operator > ( const HashedString &rhs ) const;

		BOOL operator == ( const HashedString &rhs ) const;

	private:

		void	*m_ident;
		String	m_stringID;

	};

	PSX_INLINE HashedString::HashedString( const CHAR * const pIdentStr )
		: m_ident(HashName(pIdentStr)), m_stringID( pIdentStr )
	{

	}

	PSX_INLINE ULONG HashedString::GetHashedID( void ) const
	{
		return reinterpret_cast<ULONG>(m_ident);
	}

	PSX_INLINE const CHAR * const HashedString::GetString( void ) const
	{
		return m_stringID.GetCString();
	}

	PSX_INLINE void * HashedString::HashName( const CHAR * pIdentStr )
	{
		return reinterpret_cast<void*>( PSX_SuperFastHash(pIdentStr, PSX_StrLen(pIdentStr)) );
	}

	PSX_INLINE BOOL HashedString::operator < ( const HashedString &rhs ) const
	{
		return GetHashedID() < rhs.GetHashedID();
	}

	PSX_INLINE BOOL HashedString::operator > ( const HashedString &rhs ) const
	{
		return GetHashedID() > rhs.GetHashedID();
	}

	PSX_INLINE BOOL HashedString::operator == ( const HashedString &rhs ) const
	{
		return GetHashedID() == rhs.GetHashedID();
	}

}

#endif /* _PSX_HASHED_STRING_H_ */